#include<bits/stdc++.h>
using namespace std;
int n,m,L,V;
struct car{
	int d,v,a;
}a[3010];
int light[3010];
bool vis_car[3010];
bool vis_light[3010];
int getlight[3010][3010];
int getcar[3010];
int ans,maxcnt;
void dfs(int now_light,int light_cnt){
	for(int i=0;i<n;i++){
		for(int j=0;j<maxcnt;j++){
			if(getlight[i][j]-1==now_light){
				vis_car[i]=1;
				break;
			}
		}
	}
	int flag=true;
	for(int i=0;i<n;i++){
		if(vis_car[i]==0&&getcar[i]==1){
			flag=false;
			break;
		}
	}
	if(flag){
		ans=min(ans,light_cnt);
		return;
	}
	vis_light[now_light]=1;
	for(int i=0;i<m;i++){
		if(vis_light[i]==0){
			vis_light[i]=1;
			dfs(i,light_cnt+1);
			vis_light[i]=0;
		}
	}
}
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int T;
	scanf("%d",&T);
	while(T--){
		memset(getlight,0,sizeof(getlight));
		memset(getcar,0,sizeof(getcar));
		scanf("%d%d%d%d",&n,&m,&L,&V);
		for(int i=0;i<n;i++){
			scanf("%d%d%d",&a[i].d,&a[i].v,&a[i].a);
		}
		for(int i=0;i<m;i++){
			scanf("%d",&light[i]);
		}
		int num=0;
		maxcnt=-1;
		for(int i=0;i<n;i++){
			bool flag=false;
			int cnt=0;
			for(int j=0;j<m;j++){
				if(light[j]>=a[i].d){
					int s=light[j]-a[i].d;
					double v_quick=sqrt(a[i].v*a[i].v+2*a[i].a*s);
					if(v_quick>V){
						if(!flag){
							num++;
							getcar[i]=1;
							flag=true;
						}
						getlight[i][cnt++]=j+1;
					}
				}
			}
			maxcnt=max(maxcnt,cnt);
		}
		ans=m+1;
		printf("%d ",num);
		int last_ans=m+1;
		for(int i=0;i<m;i++){
			memset(vis_car,0,sizeof(vis_car));
			memset(vis_light,0,sizeof(vis_light));
			dfs(i,1);
			last_ans=min(last_ans,ans);
		}
		printf("%d\n",m-last_ans);
	}
	return 0;
}
